package com.epam.web_project.bank.util;

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;

import org.apache.log4j.Logger;
import org.apache.log4j.chainsaw.Main;

public class AppPropertiesLoader {
	private static AppPropertiesLoader instance;
	private Properties props = new Properties();
	private static Logger logger = Logger.getLogger(AppPropertiesLoader.class);

	private AppPropertiesLoader() {
		try {
			props.load(new InputStreamReader(Main.class.getClassLoader()
					.getResourceAsStream("app.properties")));
		} catch (IOException e) {
			logger.error(e);
		}
	}
	
	public static AppPropertiesLoader getInstance() {
		if (instance==null) {
			instance=new AppPropertiesLoader();
		}
		return instance;
	}
	
	public String getProperty(String key) {
		return props.getProperty(key);
	}
}
